import {Action} from '@ngrx/store';
import {AuthState} from '../reducers/auth.reducer';

export enum ActionTypes {
  Login = '[Auth API] Login',
  LoginSuccess = '[Auth API] LoginSuccess',
  LoginFailure = '[Auth API] LoginFailure',
  Logout = '[Auth API] Logout'
}

export class Login implements Action {
  readonly type = ActionTypes.Login;

  constructor(public payload: { username: string; password: string }) {
  }
}

export class LoginSuccess implements Action {
  readonly type = ActionTypes.LoginSuccess;

  constructor(public payload: AuthState) {
  }
}

export class LoginFailure implements Action {
  readonly type = ActionTypes.LoginFailure;
}

export class Logout implements Action {
  readonly type = ActionTypes.Logout;

  constructor(public payload: AuthState) {
  }
}

export type ActionTypeUnion = Login
  | LoginSuccess
  | LoginFailure
  | Logout;
